package crud.client.event;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

import crud.client.dialog.TableCRUD;

public class SaveEvent extends GwtEvent<SaveEvent.SaveEventHandler>
{
	private TableCRUD tableCRUD;
	

	public SaveEvent(TableCRUD tableCRUD)
	{
		super();
		this.tableCRUD = tableCRUD;
	}

	// marker for handler logic in registration method
	public interface SaveEventHandler extends EventHandler
	{
		void onSave(SaveEvent event);
	}

	private static final GwtEvent.Type<SaveEvent.SaveEventHandler> TYPE = new GwtEvent.Type<SaveEventHandler>();

	public static GwtEvent.Type<SaveEventHandler> getType()
	{
		return TYPE;
	}

	@Override
	protected void dispatch(SaveEvent.SaveEventHandler handler)
	{
		handler.onSave(this);
	}

	@Override
	public GwtEvent.Type<SaveEventHandler> getAssociatedType()
	{
		return TYPE;
	}

	public TableCRUD getTableCRUD()
	{
		return tableCRUD;
	}

}
